<?php
/**
 * @license:  GNU General Public License version 3 or later
 * @autor:    Ernesto Patarroyo
 * @website:  http://openweb.co
 */

/* Funcion para detectar la version de Internet Explorer */
function ieversion() {
  preg_match('/MSIE ([0-9]\.[0-9])/',$_SERVER['HTTP_USER_AGENT'],$reg);
  if(!isset($reg[1])) {
    return -1;
  } else {
    return floatval($reg[1]);
  }
}

function browserDetect() {  
  $browser = "other";
  $browsers = array(
  	"Firefox",
    "MSIE",
    "Safari",
    "Chrome",
    "Opera",
    "Lynx"
	);
 
	foreach ($browsers as $b) {
	  if(preg_match('/' . $b . '/', $_SERVER['HTTP_USER_AGENT'])){
	    $browser = $b;
	  }
	}
	
	if ($browser == "MSIE"){
    $browser .= ieversion();
	}
	return $browser; 
}